package com.hmall.order.web;

import com.hmall.order.dto.OrderDto;
import com.hmall.order.pojo.Order;
import com.hmall.order.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("order")
public class OrderController {

    @Autowired
    private IOrderService orderService;


    /**
     * 根据订单id查询详情
     *
     * @param orderId 订单id
     * @return 订单数据
     */
    @GetMapping("{id}")
    public Order queryOrderById(@PathVariable("id") Long orderId) {
        return orderService.getById(orderId);
    }

    /**
     * 下单
     * @param orderDto
     * @return
     */
    @PostMapping
    public Long addDetail (@RequestBody OrderDto orderDto){
    Long ID=  orderService.createOrder(orderDto);
    return ID;
    }
}
